<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="d" uri="http://dgg.net/jsp/jstl/core" %>
<head>
    <meta charset="UTF-8">
    <title>证书产品配置</title>
    <c:import url="../../header.jsp"/>
    <link rel="stylesheet" href="${rootUrl}/static/css/time-status-color.css?v=${version}">
    <script> var ALLOT_REFUSED = '${ALLOT_REFUSED}';</script>
    <style>
        table.crm-table.cell-border tbody td{
            white-space: nowrap;
        }
    </style>
</head>
<div class="body-main">
    <div style="display: none;">
        <input id="generalType" value="${generalType}"/>
    </div>
    <form id="flowLongCreate" action="">
        <table class="add-table form-table">
            <tr>
                <th><span class="required">一级业态：</span></th>
                <td>
                    资质
                </td>
            </tr>
            <tr>
                <th><span class="required">二级业态：</span></th>
                <td>
                    <select id="secondBusinessId" name ="secondBusinessId" onchange="changeBussiness()">
                        <option value="">请选择</option>
                    </select>
                    <input name="secondBusinessName" id="secondBusinessName" type="hidden">
                </td>
            </tr>
            <tr>
                <th><span class="required">产品名称：</span></th>
                <td>
                    <div class="layui-input-inline">
                        <select class="select-style" id="productId"  name="productId" onchange="changeProduct()"
                                style="width:240px">
                            <option value="">请先选择二级业态</option>
                        </select>
                        <input name="productName" id="productName" type="hidden">
                    </div>
                </td>
            </tr>
        </table>
    </form>
</div>
<script src="${rootUrl}/static/js/zzsc/fine_edit_page.js?v=${version}"></script>
<script type="text/javascript" src="${basePath}/static/js/zzsc/common/dgg.verify.js?v=${version}"></script>
<script type="text/javascript">
    $(document).ready(function () {
        $.ajax({
            type: 'GET',
            url: sysInfo.basePath + '/zzsc/common/tree_book_list.do?code=BUS_YT_ZZ&&type=2&&level=2',
            dataType: 'JSON',
            success: function (data) {
                var val = data.data;
                val.forEach(function (i) {
                    $("#productName").html("");
                    $("#secondBusinessId").append('<option value='+i.code+'>'+i.name+'</option>')
                })
            }
        });
    });

    function changeBussiness() {
        var code = $("#secondBusinessId").val();
        var name =$("#secondBusinessId").find('option:selected').text();
        $("#secondBusinessName").val(name);
        $.ajax({
            type: 'GET',
            url: sysInfo.basePath + '/zzsc/common/getThreeBusiness.do?proType='+code,
            dataType: 'JSON',
            success: function (data) {
                var val = JSON.parse(data.data);
                if(val.length >0){
                    $("#productId").html("");
                    $("#productId").append('<option value="">请选择产品</option>')
                    val.forEach(function (i) {
                        $("#productId").append('<option value='+i.serialId+'>'+i.name+'</option>')
                        // console.log("fwww"+i.id)
                    })
                }else{
                    $("#productId").html("");
                    $("#productId").append('<option value="">请选择二级业态</option>')
                }
            }
        });
    }
    function changeProduct() {
        var code = $("#productId").val();
        var name = $("#productId").find('option:selected').text();
        $("#productName").val(name);
    }
</script>
</body>
</html>
